Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: "/main"
  },
  {
    path: "/main",
    component: () => import("../views/main/main.vue"),
  },
  {
    path: "/module",
    component: () => import("../views/module/module.vue"),
    redirect: "/module/message",
    children: [
      {
        path: "message",
        component: () => import("../views/message/Message.vue"),
      },
      {
        path: "article",
        name: 'article',
        component: () => import("../views/article/Article.vue")
      },
      {
        path: "archive",
        component: () => import("../views/archive/Archive.vue"),
      },
    ]
  },
  {
    path: "/statistical",
    component: () => import("../views/statistical/Statistical.vue")
  },
  {
    path: "/backend",
    component: () => import("../views/backend/Backend.vue"),
    meta: {
      keepAlive: true //需要被缓存的组件
    },
    redirect: "/backend/article",
    children: [
      {
        path: "article",
        component: () => import("../views/backend/ArticleTable.vue"),
      },
      {
        path: "personal",
        component: () => import("../views/backend/PersonalFile.vue"),
      },
      {
        path: "notice",
        component: () => import("../views/backend/Announcement.vue"),
      },
      {
        path: "message",
        component: () => import("../views/backend/Message.vue"),
      },
      {
        path: "comment",
        component: () => import("../views/backend/Comments.vue"),
      },
    ]
  },
  {
    path: "/musichome",
    component: () => import("../views/music/MusicHome.vue"),
    meta: {
      keepAlive: true //需要被缓存的组件
    },
    redirect: "/musichome/findmusic",
    children: [
      {
        path: 'findmusic',
        component: () => import("../views/music/FindMusic.vue"),
        meta: {
          keepAlive: true //需要被缓存的组件
        },
      },
      {
        path: 'playlist',
        component: () => import("../views/music/PlayList.vue"),
        meta: {
          keepAlive: true //需要被缓存的组件
        },
      },
      {
        path: 'newmusic',
        component: () => import("../views/music/NewMusic.vue"),
        meta: {
          keepAlive: true //需要被缓存的组件
        },
      },
      {
        path: 'musicvideo',
        component: () => import("../views/music/MusicVideo.vue"),
      },
      {
        path: 'search',
        name: "searchMusic",
        component: () => import("../views/music/SearchMusic.vue"),
      },
      {
        path: 'listinfo',
        name: "listinfo",
        component: () => import("../views/music/MusicList.vue"),
      },
      {
        path: 'ranking',
        component: () => import("../views/music/RankingList"),
      },
      {
        path: 'singer',
        name: "singer",
        component: () => import("../views/music/Singer"),
      },
      {
        path: 'singerSquare',
        component: () => import("../views/music/SingerSquare"),
      },


    ]
  },
  {
    path: '/details',
    component: () => import("../views/music/VideoInfo.vue"),
    meta: {
      keepAlive: false //不需要被缓存的组件
    },
  },
  {
    path: "/login",
    component: () => import("../views/login/Login.vue"),
  },
  {
    path: "/chat_login",
    component: () => import("../views/chat/ChatLogin.vue")
  },
  {
    path: "/chatroom",
    component: () => import("../views/chat/Chat.vue")
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
export default router